package com.wingsoft.homeFlow.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.wingsoft.common.annotation.Log;
import com.wingsoft.common.enums.BusinessType;
import com.wingsoft.common.result.Result;
import com.wingsoft.homeFlow.bo.HomeFlowSourceBo;
import com.wingsoft.homeFlow.bo.HomeFlowSourceQo;
import com.wingsoft.homeFlow.bo.HomeFlowSourceVo;
import com.wingsoft.homeFlow.service.HomeFlowSourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/flowSource")
public class HomeFlowSourceController {

    @Autowired
    private HomeFlowSourceService homeFlowSourceService;

    @PostMapping("/page")
    public Result<Page<HomeFlowSourceVo>> page(@RequestBody HomeFlowSourceQo homeFlowSourceQo) {
        return Result.success(homeFlowSourceService.page(homeFlowSourceQo));
    }

    @PostMapping("/get/{id}")
    public Result<?> getVoById(@PathVariable("id") String id) {
        return Result.success(homeFlowSourceService.getVoById(id));
    }

    @Log(title = "门户流水线数据源新增", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result<?> add(@RequestBody HomeFlowSourceBo homeFlowSourceBo) {
        homeFlowSourceService.add(homeFlowSourceBo);
        return Result.success();
    }

    @Log(title = "门户流水线数据源更新", businessType = BusinessType.UPDATE)
    @PostMapping("/uptById")
    public Result<?> uptById(@RequestBody HomeFlowSourceBo homeFlowSourceBo) {
        homeFlowSourceService.uptById(homeFlowSourceBo);
        return Result.success();
    }

    @Log(title = "门户流水线数据源删除", businessType = BusinessType.DELETE)
    @PostMapping("/del/{id}")
    public Result<?> delById(@PathVariable("id") String id) {
        homeFlowSourceService.delById(id);
        return Result.success();
    }

    @PostMapping("/connectionTest")
    public Result<?> connectionTest(@RequestBody HomeFlowSourceBo homeFlowSourceBo) {
        homeFlowSourceService.connectionTest(homeFlowSourceBo);
        return Result.success();
    }

}
